<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addBuyerCategoryForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$url = $control->getAjaxLinkUrl('saveBuyerCategory', NULL, array(
    'eventId'=>$eventId,
    'categoryId' => $categoryId));
$updateId = $control->getAjaxContainerId();
?>
<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function send<?php echo $categoryId; ?>() {

        var formData = new FormData($("#addBuyerCategoryForm")[0]);
        $.ajax({
            url: '<?php echo $url; ?>',
            type: 'POST',
            data: formData,
            //datatype: 'json',
            // async: false,
            beforeSend: function() {
                $("#ajax-loaderdiv").show();
            },
            success: function(html) {
                // on success do some validation or refresh the content div to display the uploaded images 
                jQuery("#<?php echo $updateId; ?>").html(html);
            },
            complete: function() {
                $("#ajax-loaderdiv").hide();
            },
            error: function(data) {
                alert("There may a error on uploading. Try again later");
            },
            cache: false,
            contentType: false,
            processData: false
        });

        return false;
    }
</script>
<legend>
    <h4>
        <?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showEventList')); ?>\
        <?php echo $control->getAjaxLink(array('name' => '买家列表', 'id' => 'showBuyerCategoryList'),array('eventId'=>$eventId)); ?>\
        <?php echo '新增买家'; ?>
    </h4>
</legend>
<div class="tabbable tabs-right" style="margin-top: 15px;"> <!-- Only required for left/right tabs -->
    <ul class="nav nav-tabs" style="margin-bottom: 15px">
        <li class="active"><a href="#tab1" data-toggle="tab"><?php echo '买家信息'; ?></a></li>       
        <li class=""><a href="#tab2" data-toggle="tab"><?php echo '买家分类'; ?></a></li>       
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab1" style="min-height: 270px">                
            <?php
            $control1 = new BUIControl('addBuyerInfo');
            $control1->addRenderView('addBuyerInfo', 'buyer_add_info',
                     array(
                        'eventId' => $eventId,
                        'categoryId' => $categoryId
                          )
                    );
            $control1->render();
            ?>  
        </div>  
        
        <div class="tab-pane" id="tab2" style="min-height: 270px">                
            <?php
            $control2 = new BUIControl('addBuyerCategory');
            $control2->addRenderView('addBuyerCategory', 'buyer_add_category', array(
                'eventId' => $eventId,
                'buyerId' => $categoryId
            ));
             $control2->render();
            ?>  
        </div> 
    </div>
</div>
<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<button class="btn" onclick="javascript:send<?php echo $categoryId; ?>()"><?php echo '保存配置信息' ?></button>


